<!--
	作者：956911785@qq.com
	时间：2019年8月13日10:46:28
	描述：积分商城搜索
-->
<template>
    <div style="width:100%;"> 
        <Tetable ref="tdtable" height="500" :columns="columns9" type="post" :paramiters="tj" :serverUrl="serverUrl"></Tetable>
        <edit ref="edit" v-on:reload="load()" :editparam="editparam"></edit>
     	<lookdhjl ref="lookdhjl" :spid="spid"></lookdhjl>
    </div> 
</template>
<script>
	import EditDelLook from "./EditDelLook";
	import edit from "./edit";
	import lookdhjl from "./jfdhjl/manage";
    export default {
    	name: "sdchss",
    	props: {
    		tj:{
    			type: Object
    		},	
    	},
        data () {
            return {
            	serverUrl:"/host/readbook/jfsc/search_jfsc.html",
                columns9: [
                    {
                        type: 'index',
                        width: 60,
                        title: '序号',
                        align: 'center'
                    },{
                        title: '商品名称',
                        key: 'SPNAME',
                        align: 'center',
                    },{
                        title: '商品总数量',
                        key: 'ALLNUM',
                        align: 'center', 
                    }, {
                        title: '每份商品兑换所需积分',
                        key: 'NEEDJF',
                        align: 'center', 
                    }, {
                        title: '已兑换',
                        key: 'YDH',
                        align: 'center', 
                    }, {
                        title: '剩余商品数量',
                        key: 'SY',
                        align: 'center', 
                    },  {
                        title: '状态',
                        key: 'SPSTATET',
                        align: 'center', 
                    }, {
                        title: '操作',
                        key: 'action',
                        width: 200,
                        align: 'center',
                        render: (h, params) => {
                            return h(EditDelLook, {
                            	props: {
                                    spstate: params.row.SPSTATE+""
                                },
                            	on: {
                                    //修改商品
                                    edit: () => {
										
										if((this.user.permission && this.user.permission.indexOf("3")>-1) || this.user.uname=='admin'){
											const rows=params.row;
											this.editparam={
												spid:rows.SPID, 
												spname:rows.SPNAME,  
												allnum:rows.ALLNUM, 
												needjf:rows.NEEDJF, 
												spurl:rows.SPURL,
												ydh:rows.YDH
											}  
											this.$refs.edit.openmodal();
										}else{
											this.$Modal.error({
											    title: "提示",
											    content:'对不起，您没有此权限！'
											});
										}
                                    	
                                    },
                                    //商品下架/上架
                                    updatestate: (spstate) =>{
										if((this.user.permission && this.user.permission.indexOf("3")>-1) || this.user.uname=='admin'){
											const rows=params.row;
											this.updatestate(rows.SPID,spstate)
										}else{
											this.$Modal.error({
											    title: "提示",
											    content:'对不起，您没有此权限！'
											});
										}
                                    },
                                    
                                    //查看兑换记录
                                    look: () =>{
                                    	this.spid=params.row.SPID;
						           		this.$refs.lookdhjl.modal0=true;
						           	},	 
						           	
                                }
                            });
                        }
                    }
                ],
                editparam:{},
                spid:''
            }
        },
        computed: {
			user: function() {
				return this.$store.state.app.user;
			}
		},
		methods: {
			//商品下架/上架
			updatestate:function(spid,spstate){
				var msg="";
				var msga="";
				if(spstate=="1"){
					msg="请确定是否下架该商品！！！";
					msga="商品下架成功";
				}else{
					msg="请确定是否上架该商品！！！";
					msga="商品上架成功";
				}
                this.$Modal.confirm({
                    title: '警告',
                    content: msg,
                    onOk: () => {
                    	//执行删除代码
                    	this.$http.get("/host/readbook/jfsc/updatestate.html?spid="+spid+"&spstate="+spstate)
						.then(datas => {
							if(datas.result){
								//操作成功 刷新页面
								this.$Message.info(msga);
								this.$refs.tdtable.load();
							}else{
								//操作成功 刷新页面
								this.$Message.info(datas.msg);
								this.$refs.tdtable.load();
							}
							
						});
                    }
                });
			},
			
			
			load(){
				this.$refs.tdtable.load();
			},


	    },
		mounted() {
		},
		watch:{
		},
		components: {
			EditDelLook,
			edit,
			lookdhjl
		}
    }
</script>


<style scoped="scoped">
	
	.ivu-table-wrapper {
		border:none;
	}
	
	.toolstipdiv{
		width: '100%';
		overflow: 'hidden';
		textOverflow: 'ellipsis';
		whiteSpace: 'normal';
		wordBreak: 'break-all';
		color:'#fff';
		text-align: center;
	}
	.toolstipdiv:hover{
		background:rgb(63, 193, 201);
	}
	
	.ivu-tooltip-rel label:hover{
		color:#0023FB;
	}
	
	.tablediv{
		height: '40px';
		overflow:'hidden';
		line-height: '40px';
	}
</style>



